
<form action="" method="post">
		<div class="form-group">
			<label for="form_title">图片</label>
		    <input type="file" class="form-control" name="img" id="form_img">
		</div>
		<div class="form-group">
			<label for="form_title">裁剪形式</label>
			<select id="form_type" name="type">
				<option value="width">宽</option>
				<option value="height">高</option>
				<option value="auto">自动</option>
			</select>
		</div>
		<div id="preview"></div>
		<button type="submit" class="btn btn-primary">提交</button>
</form>
<script type="text/javascript">
$(function(){
  $('#form_img').change(function(event) {
    var file = this.files[0];        
    if (file) {
      if(file.size > 1024 * 1024 * 2) {
        alert('图片大小不能超过 2MB!');
        return false;
      }
      var URL = window.URL || window.webkitURL;
      var imgURL = URL.createObjectURL(file);
      $('#preview').html($('<img/>').attr('src', imgURL));
    }
  });
});
</script>